<!-- This JSP page displays the links section -->
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="security" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ page session="false" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<c:set var="basePath" value="${pageContext.servletContext.contextPath}"/>
<form:form id="form2" action="${basePath}/bank/ibank/api/b2c/proceed" method="post" commandName="transaction">
<sec:authorize access="isAnonymous()">
	<p>To begin You should be authorized.<a id="ajaxLogin" href="#">Please login</a></p>
</sec:authorize>
<sec:authorize access="isAuthenticated()">
	<table>
		<tr>
			<th colspan="3">
			Customer information
			
			</th>
		</tr>
		<tr>
			<td style="width: 120px;">Name: </td>
			<td><input type="text" disabled="disabled" value="${userInfo.name},${userInfo.surname}" /></td>
			<td></td>
		</tr>
		<tr>
			<td style="width: 120px;">Person code: </td>
			<td><input type="text" disabled="disabled" value="${userInfo.personCode}" /></td>
			<td></td>
		</tr>
		<tr>
			<td style="width: 120px;">Choose account: </td>
			<td>
			 	<form:select path="accountFrom">
					<c:forEach items="${accounts}" var="account">
						<form:option value="${account[1]}" label="${account[1]} (${account[4]})" />
					</c:forEach>
				</form:select>
			</td>
			<td><form:errors path="accountFrom" /></td>
		</tr>	
		<tr>
			<td></td>
			<td><input type="submit" value="Proceed" /></td>	
		</tr>
	</table>
</sec:authorize>
</form:form>

<script>
var accountTo = $('input[id=accountTo]').val();
var transactionAmount = $('input[id=transactionAmount]').val();
var transactionDetails = $('input[id=transactionDetails]').val();
var triggerId = $('input[id=triggerId]').val();
var uniqPaymentCode = $('input[id=uniqPaymentCode]').val();
var backURL = $('input[id=backURL]').val();
$("#form2").append('<input type=hidden name=accountTo value='+ accountTo + ' />');
$("#form2").append('<input type=hidden name=transactionAmount value='+ transactionAmount + ' />');
$("#form2").append('<input type=hidden name=transactionDetails value='+ transactionDetails + ' />');
$("#form2").append('<input type=hidden name=triggerId value='+ triggerId + ' />');
$("#form2").append('<input type=hidden name=backURL value='+ backURL + ' />');
$("#form2").append('<input type=hidden name=uniqPaymentCode value='+ uniqPaymentCode + ' />');
</script>